// Here's an example of a JavaScript sleep function using Promises and async/await:

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

async function example() {
  console.log('Before sleep');
  await sleep(2000);
  console.log('After sleep');
}

example(); 

// This will log "Before sleep" immediately, then "After sleep" after a 2 second delay. 

// You can adjust the duration of the sleep by passing a different value to the sleep function.